FROM alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/node:20.16 AS build-stage
USER root

RUN echo "{\"time\":\"$BUILD_TIMESTAMP\",\"build\": \"$BUILD_NUMBER\",\"revision\": \"$SVN_REVISION_1\",\"URL\":\"$SVN_URL_1\"}" > version.json

RUN rm -f /etc/localtime && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone

WORKDIR /app

# COPY package*.json ./
COPY package.json ./
COPY .npmrc ./

RUN npm config set fetch-timeout 60000  # 设置请求超时时间为 60 秒
RUN npm config set fetch-retries 5      # 设置重试次数

RUN npm cache clean -f
RUN npm i --loglevel=http

COPY . /app

ENV NODE_ENV=production
ENV PORT=8080
EXPOSE 8080
CMD ["npm", "start"]
